/**
 * 
 */
package com.yunyike.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yunyike.mapper.RuleMapper;
import com.yunyike.model.Rule;
import com.yunyike.service.IRuleService;

/**
 * @author zhengqiang.shi
 * 2016-3-31 下午5:44:01
 */
@Service("RuleServiceImpl")
public class RuleServiceImpl implements IRuleService {

	@Autowired
	private RuleMapper ruleMapper;

	public Rule findById(String ruleId) {
		return ruleMapper.selectByPrimaryKey(ruleId);
	}

	public int save(Rule rule) {
		return ruleMapper.insertSelective(rule);
	}

	public Map<String, Rule> selectByIds(List<String> ruleIds) {
		
		List<Rule> selectByRuleIds = ruleMapper.selectByRuleIds(ruleIds);
		if(selectByRuleIds == null || selectByRuleIds.isEmpty()){
			return null;
		}
		
		Map<String, Rule> ruleMap = new HashMap<String, Rule>();
		for (Rule rule : selectByRuleIds) {
			ruleMap.put(rule.getRuleId(), rule);
		}
		
		return ruleMap;
	}
	
}
